Powershell to copy the folder and files

您所在的位置:网站首页 powershell copy Powershell to copy the folder and files

Powershell to copy the folder and files

#Powershell to copy the folder and files| 来源: 网络整理| 查看: 265

Dear All,

Currently using the below script to copy the single file but I need to copy folder, subfolder and files also. Can you someone help me with this

and I need to see the progress of the copy

$sourceFiles = Read-Host "Enter The Restored location with file Name" $rootDestFolder = Read-Host "Enter The User Request Restore Location" $resuilt =foreach($sourceFile in $sourceFiles){ $filesplit = $sourceFile.split("\") $splitcount = $filesplit.count # This example strips the drive letter & first folder ( ex: E:\Subfolder\ ) but appends the rest of the path to the rootDestFolder $destFile = $rootDestFolder + "\" + $($($sourceFile.split("\")[2..$splitcount]) -join "\") # Output List of source and dest Write-Host "" Write-Host "Source File Location : $sourceFile " -ForegroundColor Green Write-Host "Destination File Location : $destFile " -ForegroundColor yello # Create path and file, if they do not already exist $destPath = Split-Path $destFile If(!(Test-Path $destPath)) { New-Item $destPath -Type Directory } If(!(Test-Path $destFile)) { Copy-Item $sourceFile $destFile -recurse } }



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3